<%-- 
    Document   : sanpham
    Created on : Nov 16, 2012, 10:37:29 PM
    Author     : NGUYEN DANG
--%>

<%@page import="All.DTO.SanphamDTO"%>
<%@page import="All.DTO.TintucDTO"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
	ArrayList<SanphamDTO> list = (ArrayList) request.getAttribute("SanphamList");
        String id = request.getParameter("id");
        int pageID = Integer.parseInt(request.getParameter("record"));//trang hien hanh.
        
        int max = list.size();//tong so tin tuc co
        int size = 4;//tong so tin tuc 1 trang
        int cpage;//tong so trang
        cpage = (max/size)+(max%size==0?0:1);
%>
<!DOCTYPE html>
<html>
    <head>
        <title>News</title>
        <meta name="description" content="website description" />
        <meta name="keywords" content="website keywords, website keywords" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="./css/style.css" />
        <!-- modernizr enables HTML5 elements and feature detects -->
        <script type="text/javascript" src="./js/modernizr-1.5.min.js"></script>
    </head>    
    <body>
        <div id="main">
            <header>
                <jsp:include page="./file/header.jsp"></jsp:include>
            </header>
            <div id="site_content">
                <jsp:include page="./file/LeftMenu.jsp"></jsp:include>
                <div class="content">
                    <form id="contact" action="#" method="post">
                        <ul id="listnews">
                                <%
                                int tmp;
                                if(pageID+size > list.size())
                                {
                                    tmp = list.size();
                                }
                                else{
                                    tmp = pageID+size;
                                }
                                for (int i = pageID ;i < tmp; i++) {
                                        SanphamDTO sanphamDTO = list.get(i);
                                %> 
                                
                                <li>
                                    <div class="reviews_img"><img src="<%=sanphamDTO.getHinhanh()%>"" /></div>
                                    <div class="reviews_detail">
                                        <h4 class="title"><a href="./SanPhamServlet?action=detail&matin=<%=sanphamDTO.getMatintuc()%>">
                                                <%=sanphamDTO.getTieude()%></a></h4>
                                        <span class="date"><%=sanphamDTO.getNgaydang()%></span>
                                        <p><%=sanphamDTO.getTomtat()%></p>
                                    </div>
                                </li>
                                <li><hr></li>
                                <%	
                                }
                                %>
                        </ul>
                        <%
                            out.println("<a href=./SanPhamServlet?action=List&id="+id+"&record=" + (0) + ">"+ 1 +"</a>&nbsp;|&nbsp;");
                            for(int i=1; i < cpage ; i++) {
                                out.println("<a href=./SanPhamServlet?action=List&id="+id+"&record=" + (i+3) + ">"+ i +"</a>&nbsp;|&nbsp;");
                            }                                                                                              
                        %>
                    </form>
                </div>
            </div>           
            <footer>
                <jsp:include page="./file/footer.jsp"></jsp:include>
            </footer>
        </div>
        <p>&nbsp;</p>
  <!-- javascript at the bottom for fast page loading -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/jquery.easing-sooper.js"></script>
  <script type="text/javascript" src="./js/jquery.sooperfish.js"></script>
  <script type="text/javascript" src="./js/image_fade.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
      $('ul.sf-menu').sooperfish();
    });
  </script>
    </body>
</html>


